package com.flashextended.apps.logomaker.view.windows.properties.content
{
	import com.flashextended.apps.logomaker.beans.workareaobjects.ImageOnStage;
	import com.flashextended.apps.logomaker.singleton.AppControl;
	import com.flashextended.apps.logomaker.singleton.AppLocales;
	
	import mx.containers.VBox;
	import mx.controls.HSlider;
	import mx.controls.VRule;
	import mx.events.MoveEvent;
	import mx.events.SliderEvent;
	
	public class ImagePropertiesContent extends GenericPropertiesContent
	{
		protected var currentSelectedObject:ImageOnStage;
		
		public function ImagePropertiesContent()
		{
			super();
			currentSelectedObject = ImageOnStage(AppControl.getInstance().workarea.getReferenceObject());
			addImageEffects();
		}
		
		private function addImageEffects():void
		{
			var line:VRule = new VRule();
			line.percentHeight = 100;
			this.addChild(line);
			
			var vb:VBox = new VBox();
			vb.percentWidth = 100;
			vb.percentHeight = 100;
			vb.setStyle("verticalGap", 10);
			vb.setStyle("paddingLeft", 6);
			vb.setStyle("paddingTop", 6);
			
			var brightness:HSlider = new HSlider();
			brightness.maximum = 100;
			brightness.minimum = -100;
			brightness.value = currentSelectedObject.brightness;
			brightness.addEventListener(SliderEvent.CHANGE, brightnessHandler);
			vb.addChild(buildMenuLabels(brightness, AppLocales.getInstance().data.locales["brightness"]));
			
			var contrast:HSlider = new HSlider();
			contrast.maximum = 100;
			contrast.minimum = -100;
			contrast.value = currentSelectedObject.contrast;
			contrast.addEventListener(SliderEvent.CHANGE, contrastHandler);
			vb.addChild(buildMenuLabels(contrast, AppLocales.getInstance().data.locales["contrast"]));
			
			var saturation:HSlider = new HSlider();
			saturation.maximum = 100;
			saturation.minimum = -100;
			saturation.value = currentSelectedObject.saturation;
			saturation.addEventListener(SliderEvent.CHANGE, saturationHandler);
			vb.addChild(buildMenuLabels(saturation, AppLocales.getInstance().data.locales["saturation"]));								
			
			this.addChild(vb);
		}
		
		private function brightnessHandler(e:SliderEvent):void
		{
			currentSelectedObject.brightness = HSlider(e.currentTarget).value;
		}
		private function contrastHandler(e:SliderEvent):void
		{
			currentSelectedObject.contrast = HSlider(e.currentTarget).value;
		}
		private function saturationHandler(e:SliderEvent):void
		{
			currentSelectedObject.saturation = HSlider(e.currentTarget).value;
		}				
		
	}
}